package com.example.demo001.mapper;

import com.example.demo001.pojo.entity.LoginLog;
import com.example.demo001.pojo.vo.LoginStatistVo;
import com.example.demo001.pojo.vo.UserVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

@Mapper
public interface LoginLogMapper {

    @Insert("INSERT INTO login_log(user_id, ip, login_time) VALUES(#{userId}, #{ip}, #{loginTime})")
    void insert(LoginLog loginLog);

    @Select("select ip,login_time from login_log left join user on login_log.user_id = user.id where username=#{username} order by login_time desc limit 1")
    UserVo findUserVoByUsername(String username);

    ArrayList<LoginStatistVo> loginStatist(String username);
}
